import 'package:flutter_chat/common/entity/entitys.dart';
import 'package:flutter_chat/common/utils/utils.dart';

class UserApi {
  static final http = HttpUtil();

  /// 登录
  static Future<ResponseEntity> login(String username, String password) async {
    var res = await http.get("/user/doLogin", params: {
      "username": username,
      "password": password,
    });
    return res.data;
  }

  /// 注册
  static Future<ResponseEntity> register({
    required String username,
    required String password,
  }) async {
    var res = await http.post("/user/register", data: {
      "username": username,
      "password": password,
    });
    return res.data;
  }

  /// 获取用户信息
  static Future<ResponseEntity> getLoginUser() async {
    var res = await http.get("/user/getLoginUser");
    return res.data;
  }

  /// 获取登录状态
  static Future<ResponseEntity> getLoginStatus() async {
    var res = await http.get("/user/isLogin");
    return res.data;
  }
}
